<?
	include('chksession.php');
	include('conn.php');
	session_start();
    // $data = file_get_contents("php://input");
    // $objData = json_decode($data);
	
	   // $msg='';
	   //employee_search_insertdata.php?&prefx=Mr&empid=undefined&empname=SSSS&Address=SSSS&city=SSSS&email=gyan_sada@yahoo.com&phoneno=3434343&sal=434343&designation=EMPLOYEE
	   $designation= $_REQUEST['designation'];
       $prefx= $_REQUEST['prefx'];
	   $empname= $_REQUEST['empname'];
	   $address= $_REQUEST['Address'];
	   $city= $_REQUEST['city'];
	   $email= $_REQUEST['email'];
	   $phoneno= $_REQUEST['phoneno'];
	   $sal = $_REQUEST['sal'];
	   $empid = $_REQUEST['empid'];
	  
	   
	  //echo $prefx.",".$empname.",".$address.",".$city.",".$designation.",".$email.",".$phoneno.",".$empid.",".$sal;

	   //exit;
	   
		$enteredby=$_SESSION['username'];
		
		
		$sqlc="select count(*) cnt from employeemast where status = 0 and empname='".$empname."'";
		$resc=mysql_query($sqlc);
		$rowc=mysql_fetch_assoc($resc);
		if (strlen($empname)>1)
		{
			if($rowc['cnt']==0)
			{
				$sql="insert into employeemast(designation,prefx,empname,address,city,email,phoneno, sal,enteredby,entrydt)
				values('".$designation."','".$prefx."','".$empname."','".$address."','".$city."','".$email."','".$phoneno."','".$sal."','".$enteredby."',sysdate())";
								
											//echo $sql; exit;
											
				$res=mysql_query($sql);
				if($res)
					$msg='Record saved successfully';			
			}
			else
			{
				$sql="update employeemast set email='".$email."',entrydt=sysdate(),status=123 where custid=".$custid;
				$res=mysql_query($sql);
				if($res)
					$msg='Record updated successfully...';					
			}
		}
		else
		{
			$msg='Blank Name not Allowed';
		}			
	    echo $msg;
?>